<template>
	<view class="change-name public345">
		<u--input placeholder="请输入新昵称" border="bottom" maxlength="6" v-model="newName"></u--input>
		<view class="tip">
			昵称长度限制2~6个字
		</view>
		<view class="keep-btn" @click="keepNewName(newName)">
			保存
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				newName: ''
			}
		},
		onLoad(param) {
			console.log(param.currentName)
			this.newName = param.currentName ? param.currentName : '张三'
		},
		methods: {
			keepNewName(newName) {
				if (newName === '') {
					uni.showToast({
						title: '请先输入新昵称',
						icon: 'none'
					})
				} else if (newName.length < 2) {
					uni.showToast({
						title: '您输入的新昵称有误',
						icon: 'none'
					})
				} else {
					console.log('输入的新昵称', newName)
					uni.navigateBack()
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #fff;
	}

	.change-name {

		.tip {
			margin-left: 20rpx;
			font-size: 24rpx;
			line-height: 50rpx;
			color: #9E9E9E;
		}

		.keep-btn {
			width: 690rpx;
			line-height: 88rpx;
			border-radius: 44rpx;
			margin-top: 60rpx;
			background: #FF7803;
			text-align: center;
			color: #fff;
		}
	}
</style>
